#!/bin/bash
# 添加到 /etc/profile.d/
if [ -n "$SSH_CLIENT" ]; then
  echo "用户 $(whoami) 从 ${SSH_CLIENT%% *} 登录 $(hostname) 时间: $(date)" | \
  mail -s "SSH登录通知" admin@example.com
fi